import json
from datetime import datetime, timedelta

bulk_data = []
base_time = datetime(2025, 10, 30, 8, 0, 0)

for i in range(1, 1001):
    # 1. 操作行（index）
    op = {"index": {"_id": i}}
    bulk_data.append(json.dumps(op, ensure_ascii=False))  # 关键：关闭ASCII转义，保留中文

    # 2. 数据行（含中文字段）
    data = {
        "id": 1000 + i,
        "productname": f"华为全面屏{'P' if i % 3 == 0 else 'Mate' if i % 3 == 1 else 'Nova'}{i % 10 + 40}",
        "price": 2999 + (i % 3) * 1000 + (i % 10) * 99,
        "storename": f"{'京东' if i % 4 == 0 else '天猫' if i % 4 == 1 else '华为官方' if i % 4 == 2 else '苏宁'}{'自营' if i % 2 == 0 else '旗舰店'}",
        "evalcount": 5000 + i * 10,
        "purchaseindex": round(4.5 + (i % 10) * 0.15, 1),
        "storetype": f"{'自营店' if i % 3 == 0 else '旗舰店' if i % 3 == 1 else '体验店'}",
        "sku": f"HUAWEI-{'P' if i % 3 == 0 else 'Mate' if i % 3 == 1 else 'Nova'}{i % 10 + 40}-{128 if i % 3 == 0 else 256 if i % 3 == 1 else 512}G",
        "onelevel": "手机",
        "twolevel": "智能手机",
        "threelevel": "华为",
        "fourlevel": f"{'P系列' if i % 3 == 0 else 'Mate系列' if i % 3 == 1 else 'Nova系列'}",
        "updatetime": (base_time + timedelta(minutes=i * 10)).isoformat()
    }
    # 关键：ensure_ascii=False 避免中文被转义为\uXXXX
    bulk_data.append(json.dumps(data, ensure_ascii=False))

# 3. 写入文件：明确指定encoding='utf-8'
with open("bulk_data_1000.json", "w", encoding="utf-8") as f:
    f.write("\n".join(bulk_data) + "\n")